package com.baitiaojun.api.util;

import lombok.Getter;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @类名 ConstantUtil
 * @描述
 * @作者 白条君
 * @创建日期 2022/10/25 20:14
 * @版本 1.0
 */
public class ConstantUtil {

    @Getter
    public enum status {
        //失败状态码
        ERROR(0),
        //成功状态码
        SUCCESS(1);

        private final int status;

        status(int status) {
            this.status = status;
        }
    }

    //userinfo相关常量
    public static final String DEFAULT_NICKNAME_PREFIX = "bili_";
    public static final String DEFAULT_AVATAR = "group1/M00/00/05/CtM3CGPH406AQhU0AAO0wvMlGpo592_big.jpg";
    public static final String DEFAULT_SIGN = "这个家伙很懒，还没留下签名";
    public static final String UPLOAD_AVATAR_FILE_GROUP = "group1";

    @Getter
    public enum Gender {
        MALE(0),
        FEMALE(1),
        UNKNOWN(2);

        private final int gender;

        Gender(int gender) {
            this.gender = gender;
        }
    }

    public static final String CHAR_SET_UTF8 = "UTF-8";

    public static final String ISSUER = "imooc-bilibili服务端签发者";

    public enum TokenType {
        ACCESS, REFRESH
    }

    public static final Long ACCESS_TOKEN_TIMEOUT = 1L;
    public static final Long REFRESH_TOKEN_TIMEOUT = 7L;
    public static final Long REDIS_USER_INFO_TIMEOUT = REFRESH_TOKEN_TIMEOUT;
    public static final Long REDIS_ONLINE_TIMEOUT = REFRESH_TOKEN_TIMEOUT;
    public static final TimeUnit OUT_TIMEUNIT = TimeUnit.DAYS;

    @Getter
    public enum GroupType {
        SPECIAL("0"), DEFAULT("1");

        private final String type;

        GroupType(String type) {
            this.type = type;
        }
    }

    @Getter
    public enum Field {
        USER_FOLLOWING("userFollowing"),
        AUTHORIZATION("Authorization"),
        USER_AND_USERINFO("userAndUserInfo"),
        REFRESH_TOKEN("refreshToken"),
        FANS("fans"),
        FOLLOWING_GROUP("followingGroup"),
        COLLECTION_GROUP("collectionGroup"),
        VIDEO_COLLECTION("videoCollection");

        private final String key;

        Field(String key) {
            this.key = key;
        }
    }

    public static final String NO = "1";
    public static final String SIZE = "10";

    //重发失败功的冗余信息状态修改为2，初次发送或者消息被回退的冗余信息状态修改为0，消息确认发布成功的冗余信息状态修改为1
    public static final String DEFAULT_STATUS = "0";
    public static final String SUCCESS_STATUS = "1";
    public static final String FAIL_STATUS = "2";

    //会员等级
    public static final String ROLE_LV0 = "Lv0";
    public static final String ROLE_LV1 = "Lv1";
    public static final String ROLE_LV2 = "Lv2";
    public static final String ROLE_LV3 = "Lv3";
    public static final String ROLE_LV4 = "Lv4";
    public static final String ROLE_LV5 = "Lv5";
    public static final String ROLE_LV6 = "Lv6";

    //断点续传相关的常量
    public static final String GROUP1 = "group1";
    public static final String UPLOAD_SIZE_KEY = "upload_size_key";
    public static final String UPLOAD_NO_KEY = "upload_no_key";
    public static final String PATH_KEY = "path_key";
    public static final Integer SLICE_SIZE = 1024 * 1024 * 10;
    public static final String TEMP_FILE_SLICE_PATH = "/Users/baitiaojun/java后端学习/java项目/java微服务项目/毕设-视频弹幕网站/imooc-bilibili/imooc-bilibili-video/slicefile";

    //分区分页加载页数
    public static final String AREA_VIDEO_PAGE_NO = "1";
    public static final String AREA_VIDEO_PAGE_SIZE = "20";

    //AES加密和解密的种子
    public static final String AES_SEED = "254362781074067456";

    @Getter
    public enum CollectionType {
        CUSTOM("1"), DEFAULT("0");

        private final String type;

        CollectionType(String type) {
            this.type = type;
        }
    }

    //文件下载的临时存放路径
    public static final String TEMP_FILE_DOWNLOAD_PATH = "/Users/baitiaojun/java后端学习/java项目/java微服务项目/毕设-视频弹幕网站/imooc-bilibili/imooc-bilibili-video/tempfile/";

    //视频评论所需要的常量
    public static final String CHILD_VIDEO_COMMENT_PAGE_NO = "1";
    public static final String CHILD_VIDEO_COMMENT_PAGE_SIZE = "10";
    public static final String VIDEO_COMMENT_PAGE_NO = "1";
    public static final String VIDEO_COMMENT_PAGE_SIZE = "20";

    //websocket所使用的常量
    public static final String WEB_SOCKET_OPEN_STATUS = "1";

    //搜索分页加载所需常量
    public static final String FULL_TEXT_SEARCH_PAGE_NO = "1";
    public static final String FULL_TEXT_SEARCH_PAGE_SIZE = "20";

    //观看次数和评论条数的key
    public static final String VIEW_COUNT = "viewCount";
    public static final String COMMENT_COUNT = "commentCount";
    public static final String LIKE_COUNT = "likeCount";

    //首页加载视频常量
    public static final String HOME_VIDEO_PAGE_NO = "1";
    public static final String HOME_VIDEO_PAGE_SIZE = "20";

    //百度APi提供的accesstoken
    public static final String BAIDU_ACCESS_TOKEN = "baiduAccessToken";

    //发布动态类型
    public static final String VIDEO_TYPE = "0";
    public static final String DAILY_TYPE = "1";
    public static final String SPECIAL_COLUMN_TYPE = "2";

    public static final String VIDEO_MOMENTS_DESCRIPTION = "投稿了视频";

    //防止用户重复登录的key
    public static final String ONLINE = "online";

    //用户硬币数存储到redis的key
    public static final String USER_COINS = "userCoins";

    //分页也加载动态信息
    public static final String USER_MOMENTS_PAGE_NO = "1";
    public static final String USER_MOMENTS_PAGE_SIZE = "10";

    public static final String BLOOM_FILTER_NAME = "bloomFilter";

    public static final Lock LOCK_LIKE_COUNT = new ReentrantLock();
    public static final Lock LOCK_VIEW_COUNT = new ReentrantLock();
    public static final Lock LOCK_COMMENT_COUNT = new ReentrantLock();

    public static final String OPERATION_TYPE_LIKE = "0";
    public static final String OPERATION_TYPE_COLLECTED = "1";
    public static final String OPERATION_TYPE_COIN_OPERATED = "2";

    public static final String PICTURE_URL = "picUrl";

    public static String COMMENT_APPEND_KEY = "comment_append_key";
}